# -*- coding: utf-8 -*-
from django.test import TestCase,Client
from django.http import HttpResponse
from cron import generate_all_user_consumption
from models import RecordTime,HourRecord
from django.db import models

class ConsumptionViewTest(TestCase):
    
    #测试添加消费记录
    def test_creat_consumption(self):
        c =Client()
        rep = c.get("/billing/ajax_consumption_list/",{})
        print rep
        # 测试http请求的返回码是否正确
        #self.assertEqual(rep.status_code,200)
        # 测试response的内容是否包含字符串
        #self.assertContains(rep,"OK")
        # 测试response的内容是否包含字符串 方法二
        #self.assertTrue('OK' in rep.content)
        
    def test_list_consumption(self):
        c =Client()
        rep = c.get("/billing/consumption_list/",{})
        self.assertEqual(rep.status_code,200)
        
    def test_get_consumption_by_project_id(self):
        query = HourRecord.objects.all().query 
        query.group_by = ['project_id'] 
        book_list = QuerySet(query = query, model = HourRecord)
        print book_list 
        pass
    
    def test_job_schedule(self):
        print RecordTime.objects.all()
        